package com.javademo.iotest;

import lombok.extern.slf4j.Slf4j;

import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

@Slf4j
public class ReaderTest {
    public static void main(String[] args) {
        char[] chars;
        try(Reader reader = new FileReader("test.txt")){
            log.info("文件读取准备：{}", reader.ready());
            int len = reader.read();
            chars = new char[len];
            reader.read(chars);
            log.info("文件读取长度：{}", len);
            log.info("文件读取内容：{}", new String(chars));
        } catch (IOException e) {
            log.info("文件读取异常：{}", e.getMessage(), e);
        }
    }
}
